package cn.itsource.pethome.user.controller;

import cn.itsource.pethome.basic.util.Result;
import cn.itsource.pethome.user.domain.dto.UserDto;
import cn.itsource.pethome.user.service.ILoginInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/login")
public class LonginController {
    @Autowired
    private ILoginInfoService loginInfoService;

    /**
     * 登录(后台和前端都是用的共同接口)
     * @param userDto
     * @return
     */
    @PostMapping()
    public Result login(@RequestBody UserDto userDto){
        try {
            return loginInfoService.login(userDto);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, e.getMessage());
        }
    }
}
